package com.ayu.shortlink.settlement.service.handler.strategy;

import cn.hutool.core.bean.BeanUtil;
import com.ayu.shortlink.settlement.common.enums.PayChannelEnum;
import com.ayu.shortlink.settlement.dto.req.PayCommand;
import com.ayu.shortlink.settlement.dto.resp.PayRespDTO;
import com.ayu.shortlink.settlement.service.bases.pay.AbstractPayCreateOrderHandler;
import com.ayu.shortlink.settlement.service.bases.strategy.AbstractPayCreateOrderStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 支付宝创建订单策略
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class AliPayCreateOrderStrategy implements AbstractPayCreateOrderStrategy<PayCommand, PayRespDTO> {
    private final AbstractPayCreateOrderHandler abstractPayCreateOrderHandler;
    @Override
    public String mark() {
        return PayChannelEnum.ALI_PAY.getName();
    }

    @Override
    public void execute(PayCommand requestParam) {
        abstractPayCreateOrderHandler.handler(requestParam);
    }

    @Override
    public PayRespDTO executeResp(PayCommand requestParam) {
        return BeanUtil.toBean(abstractPayCreateOrderHandler.handler(requestParam),PayRespDTO.class);
    }
}
